package com.wolfalpha.utron.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.wolfalpha.utron.R;
import com.wolfalpha.utron.activity.base.BaseNormalActivity;
import com.wolfalpha.utron.service.impl.AppServiceImpl;
import com.wolfalpha.utron.ui.UIHelper;
import com.wolfalpha.utron.utils.ThreadPoolUtils;

/**
 * 反馈界面
 */
public class FeedBackActivity extends BaseNormalActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feedback);
        setTvTitle("意见反馈");

        final EditText content = (EditText) findViewById(R.id.et_feedback);

        findViewById(R.id.btn_feedback).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (TextUtils.isEmpty(content.getText().toString())) {
                    UIHelper.ToastMessage(FeedBackActivity.this, "请先输入反馈内容");
                } else {
                    ThreadPoolUtils.execute(new Runnable() {
                        @Override
                        public void run() {
                            boolean result = new AppServiceImpl().sendFeedback(content.getText().toString());
                            if (result) {
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        UIHelper.ToastMessage(FeedBackActivity.this, "发送成功,感谢您的反馈");
                                        finish();
                                    }
                                });
                            } else {
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        UIHelper.ToastMessage(FeedBackActivity.this, "发送失败，请重试");
                                    }
                                });
                            }
                        }
                    });
                }
            }
        });
    }


}
